package com.apes.autoparts.supplier.jikugroup;

import com.apes.framework.jpa.BaseModel;
import com.apes.framework.jpa.DefaultPersistListener;
import com.apes.framework.jpa.comment.Comment;
import com.apes.framework.jpa.generator.ApesGenerator;
import com.apes.framework.util.ApesConst;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.SelectBeforeUpdate;

import javax.persistence.*;

/**
 * Created by lishikun on 2021/5/25 17:28
 */
@Getter
@Setter
@SelectBeforeUpdate
@DynamicInsert
@DynamicUpdate
@Entity
@EntityListeners(DefaultPersistListener.class)
@Table(name = JiKuGroupDebugItem.CONST_TABLE_NAME)
public class JiKuGroupDebugItem extends BaseModel {
    public static final String CONST_TABLE_NAME = "ji_ku_group_debug_item";

    @Id
    @Comment("流水码")
    @Column(name = "id", length = 32)
    @ApesGenerator(code = CONST_TABLE_NAME, name = "积准库存信息")
    private String id;

    @ManyToOne(optional = false)
    @JoinColumn(name = "ji_ku_group_id", referencedColumnName = "id")
    @Comment("积准")
    private JiKuGroupDebug jiKuGroupDebug;

    @Comment("唯一库存Id")
    @Column(name = "stock_id")
    private Integer stockId = 0;

    @Comment("唯一配件Id")
    @Column(name = "parts_id")
    private Integer partsId = 0;

    @Comment("库存总数")
    @Column(name = "stock_num", columnDefinition = ApesConst.FIELD_MONEY_16_4_0)
    private double stockNum;

    @Comment("售价")
    @Column(name = "sales_price", columnDefinition = ApesConst.FIELD_MONEY_16_4_0)
    private double salesPrice;

    @Comment("子编码")
    @Column(name = "sub_code")
    private String subCode;

    @Column(name = "on_sale", nullable = false,columnDefinition = "number(1,0) default 1")
    @Comment("是否上架")
    private Boolean onSale = true;
}
